package com.woniu.sharepark.platformsystem.controller;

import com.woniu.sharepark.common.pojo.Login;
import com.woniu.sharepark.platformsystem.service.VoucherService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author DELL
 * @date 2019/6/12 23:53
 * version v1.0
 */
@RequestMapping("voucher")
@Controller
public class VouchController {

    @Autowired
    private VoucherService voucherService;

    /**
    * 查找当前用户所拥有的代金券
    * @title findVouchers
    * @param
    * @return java.util.List
    * @author DELL
    * @date 2019/6/12 23:54
    **/

    @RequestMapping("/findVouchers")
    @ResponseBody
    public List findVouchers(){
        Session session = SecurityUtils.getSubject().getSession();
        Login login = (Login) session.getAttribute("currentUser");
        List vouchers = voucherService.findVouchers(login.getUserInfo().getuId());
        System.out.println(vouchers);
        return vouchers;
    }
}
